<template>
    <div id="reply">
        <p class="rtitle">{{this.$route.query.cname}}</p>
        <div class="rcontent">
            <textarea v-model="content" name="" id="" cols="30" rows="10" placeholder="在这里留言"></textarea>
            <div v-if="this.$route.query.icardid">
                <el-radio v-model="isOpen" label="1">公开</el-radio>
                <el-radio v-model="isOpen" label="0">不公开</el-radio>
            </div>
            <!-- <p v-if="!isOpen && this.$route.query.icardid" class="noOpen" @click="isOpen=!isOpen" style="text-align:center;">不公开</p>
            <p v-else-if="isOpen && this.$route.query.icardid" class="toReply"  @click="isOpen=!isOpen" style="text-align:center;">公开</p> -->
            <p class="toReply" @click="sendblog" style="text-align:center;">留言</p>
        </div>
        
    </div>
</template>

<script>
import fetch from '@/config/fetch.js'
export default {
    data(){
        return {
            content:'',
            isOpen:'1'
        }
    },
    methods:{
        sendblog(){
            let self = this
            let username = decodeURIComponent(sessionStorage.username)
            let icardid=this.$route.query.icardid
            let icarduid=this.$route.query.icarduid
            let ireplyid=this.$route.query.ireplyid
            if(icardid && icarduid){
                var sendjson={icardid:icardid,icarduid:icarduid,content:self.content,bflag:self.isOpen}
            }else{
                var sendjson={ireplyid:ireplyid,content:self.content,bflag:true}
            }
            
            if(self.content == ''){
                self.$message({
                        duration: 2000,
                        message: '请输入内容',
                        type: 'error'
                    })
                return false
            }else{
                
                let responseData = fetch('/blog/saveBlog',sendjson,'POST')
                responseData.then((res)=>{
                    if(res.result==1){
                        self.$message({
                            duration: 2000,
                            message: '留言成功',
                            type: 'success'
                        })
                        self.$router.go(-1);
                    }else{
                        self.$message({
                            duration: 2000,
                            message: res.msg,
                            type: 'error'
                        })
                    }
                })
            }
           
        },
    }
}
</script>

<style scoped>
#reply {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: absolute;
    width: 100%;
    height: 100%;
    background: #efefef;
}
#reply .rtitle{
    height: 3rem;
    line-height: 3rem;
    font-size: 1.2rem;
    width: 100%;
    background: -moz-linear-gradient(top, #00AA76 0%, #1ACCAC 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00AA76), color-stop(100%,#1ACCAC));
    background: -webkit-linear-gradient(top, #00AA76 0%,#1ACCAC 100%);
    background: -o-linear-gradient(top, #00AA76 0%,#1ACCAC 100%);
    background: -ms-linear-gradient(top, #00AA76 0%,#1ACCAC 100%);
    background: linear-gradient(to right, #00AA76 0%,#1ACCAC 100%);
    color: #303133;
    color:#ffffff;
    padding:0 1rem;
    box-sizing: border-box;
}
#reply .noOpen{
    height: 3rem;
    line-height: 3rem;
    font-size: 1.2rem;
    width: 100%;
    color: #303133;
    box-sizing: border-box;
    border-radius: 0.3rem;
    margin:0 auto;
    margin-top:1rem;
    background: #d6d6d6;
}
#reply .toReply{
    height: 3rem;
    line-height: 3rem;
    font-size: 1.2rem;
    width: 100%;
    background: -moz-linear-gradient(top, #00AA76 0%, #1ACCAC 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00AA76), color-stop(100%,#1ACCAC));
    background: -webkit-linear-gradient(top, #00AA76 0%,#1ACCAC 100%);
    background: -o-linear-gradient(top, #00AA76 0%,#1ACCAC 100%);
    background: -ms-linear-gradient(top, #00AA76 0%,#1ACCAC 100%);
    background: linear-gradient(to right, #00AA76 0%,#1ACCAC 100%);
    color: #303133;
    color:#ffffff;
    box-sizing: border-box;
    border-radius: 0.3rem;
    margin:0 auto;
    margin-top:1rem;
}
.rcontent{
    padding: 0 1rem;
    padding-top: 1rem;
    box-sizing: border-box;
}
.rcontent textarea{
    width:100%;
    padding:1rem;
    box-sizing: border-box;
}
</style>
